<template>
	<view>
		<u-navbar title-color="#000" :isBack="true" back-icon-color="#000" height="60" title="我的收藏"></u-navbar>
		<mescroll-body @init="mescrollInit" :up="{empty:{use:true}}" :down="{use:false}" @up="upCallback" height="60%">
			<view class="collection-list">
				<block v-for="collection in collectionList">
					<view class="collection-item" @click="getKnowInfo(collection.rticleaId)">
						<view class="title">{{collection.rticleaTitle}}</view>
						<view class="icon">
							<image src="../../../static/icon/跳转.png"></image>
						</view>
					</view>
				</block>
			</view>
		</mescroll-body>
	</view>
</template>

<script>
	import bodyItem from '../../../components/body-item.vue';
	export default {
		components: {
			bodyItem
		},
		data() {
			return {
				collectionList: []
			};
		},
		methods: {
			downCallback(mescroll) {
				mescroll.resetUpScroll()
			},
			getKnowInfo(rticleaId) {
				this.$comm.navigateTo('/pages/know-info/know-info?rticleaId=' + rticleaId)
			},
			upCallback(mescroll) {
				this.$api.getCollectionList({
					page: mescroll.num,
					limit: mescroll.size
				}).then(res => {
					if (res.code) {
						if (mescroll.num == 1) {
							this.collectionList = res.data
						} else {
							this.collectionList = this.collectionList.concat(res.data)
						}
						mescroll.endSuccess(res.data.length, res.data.length >= mescroll.size);
					}
				}).catch(() => {
					mescroll.endErr();
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #FFFFFF;
		min-height: 100vh;
	}

	.collection-list {

		.collection-item {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 30upx 40upx;
			border-bottom: 1upx solid #ddd;

			&:first-child {
				border-top: 1upx solid #ddd;
			}

			.title {
				font-weight: bold;
				font-size: 30upx;
			}

			.icon {
				image {
					width: 40upx;
					height: 40upx;
				}
			}
		}
	}
</style>
